package cn.bx.bid.ctrl;


/*
@Controller
public class UserControllerNo1 {
    @Resource
    UserService userService;
@PostMapping("login")
    public String login(HttpServletRequest request, @RequestParam("username") String n, @RequestParam(name = "pass", required = true) String p){

        if (n.startsWith("java63")&&p.equals(("123456"))){
            request.getSession().setAttribute("USER",n);
            return  "welcome.jsp";
        }
        request.setAttribute("msg","密码或用户名错误");
        return "fail.jsp";
    }
    @PostMapping("useradd")
    public String reg(@ModelAttribute("u") User user, HttpServletRequest req) {
        // ServletContext servletContext = s.getServletContext();
        // servletContext.getRealPath("")
//        CharacterEncodingFilter f=null;
//        f.setEncoding("utf-8");
//        f.setForceEncoding(true);
        //ContextLoaderListener x=null;
        int r = userService.add(user);
        req.setAttribute("msg", r > 0 ? "注册成功" : "注册失败");
        // System.out.println("新用户：" + user + "被保存了");
        //return "regsuccess.jsp";
        //  return "/WEB-INF/pages/regsuccess.jsp";
        return "regsuccess";
    }
    //新管理员注册
    @RequestMapping("adminRegister")
    public String register(@ModelAttribute("u") User user) {
        System.out.println("新管理员：" + user + "保存成功了");
        //return "registerOk.jsp";
        //return "/WEB-INF/pages/registerOk.jsp";
        return "registerOk";
    }


    @GetMapping("usersearch")
    public ModelAndView search(@RequestParam(name = "page", defaultValue = "1") int pageNo, @RequestParam(name = "limit", defaultValue = "10") int limit, @RequestParam(name = "name", required = false) String name, @RequestParam(name = "startDate", required = false) Date start, @RequestParam(name = "endDate", required = false) Date end) {
        ModelAndView mv = new ModelAndView();
        Page<User> page = this.userService.paging(pageNo, limit, name, start, end);
        mv.addObject("p", page);
        mv.setViewName("admin-list");
        return mv;
    }
    */
/*  @GetMapping("usersearch")
    public ModelAndView search() {
        //HttpServletRequest request,

        List<User> users = new ArrayList<>();
        for (int i = 1; i <= 10; i++) {
            users.add(new User(i * 10L, 1L, "liu" + i, "111" + i, "111" + i, "11111" + i, "2222" + i, null, null));
        }
        ModelAndView mv = new ModelAndView();
        //mv.setViewName("userlist.jsp");
        mv.setViewName("userlist");
        mv.addObject("users", users);
        return mv;
    }*//*

//    public String login(HttpServletRequest request){
//        String name=request.getParameter("")
//        return "";
//    }
    @GetMapping(value = "user-del-{id}")
    public String del(@PathVariable("id") long id,Model m){
        long[] ids = new long[]{id};
        int flag = userService.batchDel(ids);
        if(flag == 1){
            m.addAttribute("msg","删除成功");
        }else{
            m.addAttribute("msg","删除失败");
        }
        return "userlist";
    }
//日期转换器
    @InitBinder
    public void initBinder(WebDataBinder binder) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
        // true:允许输入空值，false:不能为空值
    }
    @PostMapping("userupdate")
    public String updent(@ModelAttribute("u") User user, HttpServletRequest req) {

        int r = userService.update(user);
        req.setAttribute("msg", r > 0 ? "修改成功" : "修改失败");
        return "regsuccess";
    }
    @GetMapping("user-update-{id}")
    public String toUpdate(@PathVariable("id") long id, Model m){
        User u=this.userService.get(id);
        m.addAttribute("user",u);//也可以带对象给视图
        return "userupdate";
    }

    //局部，只能处理UserController中的异常
    @ExceptionHandler
    public String handlerException(Exception e){
        e.printStackTrace();//Log4j
        return "error";
    }
}
*/






